#include "ResetModule.h"
#include "SimpleCompletion.h"

struct rt_semaphore reset_sem;
struct rt_mutex reset_mutex;

void INT_SRC_PORT_EIRQ6_IrqCallback(void) {
	// 处理按键中断
	if (GPIO_ReadInputPins(RESET_PORT, RESET_PIN) == PIN_SET) { // 抬起事件
		if ( rt_mutex_take(&reset_mutex, RT_WAITING_NO) == RT_EOK ) { // 仅仅复位
			__NVIC_SystemReset();
		}else{ // 回复出厂设置
			completion_done(&reset_sem);
		}
		TMR2_Stop(CM_TMR2_2, TMR2_CH_B);
		TMR2_SetCountValue(CM_TMR2_2, TMR2_CH_B, 0U);
	}else{ // 按下事件
		
	}
	// 处理按键中断
}

/* INT_SRC_TMR2_2_CMP_B Callback. */
void INT_SRC_TMR2_2_CMP_B_IrqCallback(void) {
  //add your codes here
	rt_mutex_take(&reset_mutex, RT_WAITING_NO);
}

